from django.db import models
import random
# 定义2018年电影数据模型
class movie2018(models.Model):
    name = models.CharField(max_length=50)
    year = models.IntegerField()
    boxOffice = models.CharField(max_length=80)
    def __str__(self):
        return self.name
    class Meta:
        db_table = '2018boxoffice'

# 定义2019年电影数据模型
class movie2019(models.Model):
    name = models.CharField(max_length=50)
    year = models.IntegerField()
    boxOffice = models.CharField(max_length=80)
    def __str__(self):
        return self.name
    class Meta:
        db_table = '2019boxoffice'

# 定义2020年电影数据模型
class movie2020(models.Model):
    name = models.CharField(max_length=50)
    year = models.IntegerField()
    boxOffice = models.CharField(max_length=80)
    def __str__(self):
        return self.name
    class Meta:
        db_table = '2020boxoffice'

# 定义2021年电影数据模型
class movie2021(models.Model):
    name = models.CharField(max_length=50)
    year = models.IntegerField()
    boxOffice = models.CharField(max_length=80)
    def __str__(self):
        return self.name
    class Meta:
        db_table = '2021boxoffice'

# 定义2022年电影数据模型
class movie2022(models.Model):
    name = models.CharField(max_length=50)
    year = models.IntegerField()
    boxOffice = models.CharField(max_length=80)
    def __str__(self):
        return self.name
    class Meta:
        db_table = '2022boxoffice'
# 定义排行榜数据的模型
# class BoxOffice(models.Model):
#     name = models.CharField(max_length=50)
#     date = models.IntegerField()
#     types = models.CharField(max_length=50)
#     direct = models.CharField(max_length=50)
#     boxoffice = models.CharField(max_length=80)
#     def __str__(self):
#         return self.name
#     class Meta:
#         db_table = 'boxOffice'
# # 定义评论数据模型
# class Comment(models.Model):
#     title = models.CharField(max_length=50)
#     favourable = models.IntegerField()
#     differ = models.IntegerField()
#     general = models.IntegerField()
#     def __str__(self):
#         return self.title
#     class Meta:
#         db_table = 'comment'
# # 电影详情数据模型
# class FilmInfo(models.Model) :
#     title  = models.CharField(max_length=50)
#     types =  models.CharField(max_length=200)
#     actors =  models.CharField(max_length=500)
#     score = models.FloatField()
#     release_date = models.DateTimeField()
#     regions = models.CharField(max_length=200)
#     vote_count = models.IntegerField()
#     def __str__(self):
#         return self.title
#     class Meta:
#         db_table = 'filmInfo'
# # 电影推荐模型
# class Recommend(models.Model):
#     content=models.TextField()
#     def __str__(self):
#         return self.content
#     class Meta:
#         db_table = 'recommend'

# 获取电影数据
def getMovie2018():
     allData = movie2018.objects.all()
     return allData


def getMovie2019():
    allData = movie2019.objects.all()
    return allData


def getMovie2020():
    allData = movie2020.objects.all()
    return allData


def getMovie2021():
    allData = movie2021.objects.all()
    return allData


def getMovie2022():
    allData = movie2022.objects.all()
    return allData

#
# # 获取排行榜数据
# def getBoxTop():
#     allData = BoxOffice.objects.all()
#     return allData
# # 获取评论数据
# def getComment(name:str):
#     data = Comment.objects.get(title=name)
#     return data
# # 获取电影类型行
# def getTypes():
#     data = FilmInfo.objects.values_list('types')
#     return data
#
# # 获取年份分组数据
# def getDateNum():
#     data = FilmInfo.objects.values_list('release_date')
#     return data
# # 获取随机的一个数据
# def getRandom():
#     count = Recommend.objects.count()
#     print(count)
#     rand = random.randint(0,count-1)
#     return Recommend.objects.get(id=rand)
# #